


import FormItem from '@/components/vue-flow/nodes/formItem.vue'
import { PlusIcon, AlertCircleIcon, ChevronDown, Minus} from 'lucide-vue-next'
import { Textarea } from '@/components/ui/textarea'
import { Label } from '@/components/ui/label'
import { Input } from '@/components/ui/input'
import { Switch } from '@/components/ui/switch'
import { Button } from '@/components/ui/button'
import Holder from '@/components/vue-flow/nodes/holder.vue'
import SelectComponent from '@/components/vue-flow/nodes/selectComponent.vue'
let pushTemplate ={
  FormItem: {
    type: FormItem,
    props: {
      required: true,
    },
    children: [
      {
        label: '名称',
        key: 'name',
        type: Input,
        isRequired: true,
        placeholder: '请输入名称',
        props:{
          modelValue:'',
        }
      },
      {
        label: '描述',
        key: 'description',
        type: Input,
        isRequired: false,
        placeholder: '请输入名称',
        props:{
          modelValue:'1'
        }
      },
      {
        label: '类型',
        key: 'type',
        type: SelectComponent,
        isRequired: true,
        Options: [
          { label: '文本', value: 'text' },
          { label: '数字', value: 'number' },
          { label: '布尔', value: 'boolean' },
          { label: '选项', value: 'options' }
        ]
      },
      {
        label: '是否必要',
        key: 'isRequired',
        type: Switch,
        isRequired: true
      },
      {
        label: '',
        key: 'operation',
        type: Minus,
        props:{
          size:16,
          color:'#888d92',
          onclick:(e)=>{
            e.stopPropagation();
            const index = e.target.getAttribute('index');
            deleteItem(index)  
          }
        }
      }
    ]
  }
}
const add=() => {
  template.formData.formItems.push(pushTemplate)
}
const deleteItem=(index)=> {
  // const test = template.formData.formItems.splice(index, 1)
  template.formData.formItems.splice(index, 1)
  console.log(index,template.formData.formItems)
  // .splice(index, 1)
}
const template = {
  titleBar: {
    title: '输入',
    description: '请提供需要添加到提示词中的信息，这些信息可以被提示词引用。',
    icon: {
      icon: PlusIcon,
      size: 16,
      color: 'gray-400',
      func: () => {
        console.log('点击了添加')
        handleClickAddBtn()
      }
    }
  },
  formData: {
    labels: [
      { label: '名称', key: 'name', isRequired: true },
      { label: '描述', key: 'description', isRequired: false },
      { label: '类型', key: 'type', isRequired: true },
      { label: '是否必填', key: 'isRequired', isRequired: true, className: 'justify-self-end' },
    ],
    formItems: [
      {
        FormItem: {
          type: FormItem,
          props: {
            required: true,
            readonly: true
          },
          children: [
            {
              label: '名称',
              key: 'name',
              type: Input,
              isRequired: true,
              placeholder: '请输入名称',
            },
            {
              label: '描述',
              key: 'description',
              type: Input,
              isRequired: false,
              placeholder: '请输入名称'
            },
            {
              label: '类型',
              key: 'type',
              type: SelectComponent,
              isRequired: true,
              Options: [
                { label: '文本', value: 'text' },
                { label: '数字', value: 'number' },
                { label: '布尔', value: 'boolean' },
                { label: '选项', value: 'options' }
              ]
            },
            {
              label: '是否必填',
              key: 'isRequired',
              type: Switch,
              isRequired: true
            },
            {
              label: '',
              key: 'holder',
              type: Holder,
            }
          ]
        }
      },
      {...pushTemplate}
    ]
    // actionBar: {
    //   label: '添加',
    //   func:()=>{
    //     console.log('点击了添加')
    //     handleClickAddBtn()
    //   }
    // }
  }
}

export {
  add,
  deleteItem,
  template,
  pushTemplate
}

// const templateOperaiton = new TemplateOperation(tempalte)
// export default templateOperaiton
